<?php

use yii\db\Migration;

/**
 * Handles the creation of table `good_right`.
 */
class m190126_061156_create_good_right_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('good_right', [
            'id'        => $this->primaryKey(),
            'item_name' => $this->string(64)->notNull(),
        ], 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB');

        $this->addForeignKey('fk_good_goodRight_right', 'goods', 'right', 'good_right', 'id');
        $this->addForeignKey('fk_goodright_vip_item', 'good_right', 'item_name', 'vip_item', 'name');
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('good_right');
        $this->dropForeignKey('fk_good_goodRight_right', 'goods');
        $this->dropForeignKey('fk_goodright_vip_item', 'good_right');
    }
}
